how to avoid common mistakes in Java